package com.dq;

import com.dq.utils.FileReadUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Springboot给我们提供了两种“开机启动”某些方法的方式：ApplicationRunner和CommandLineRunner
 *
 * @author jcf
 * @since 2018/9/10
 */
@Component
public class ApiAutoRun implements ApplicationRunner {

    @Value("${spring.profiles.active}")
    private String area;
    @Value("${spring.application.name}")
    private String projectName;
    @Value("${server.port}")
    private String port;

    @Override
    public void run(ApplicationArguments var1) throws Exception {
        List<String> lines = FileReadUtils.readLinesJarByIo("loading/launch.txt");
        for (String line : lines) {
            System.out.println(line);
        }

        System.out.println(String.format("---->   运行环境: %s,     port: %s,     projectName: %s", area, port, projectName));
    }
}